package com.itheima.service.imp;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.UserDao;
import com.itheima.dao.UserDaoJpa;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class UserServiceImp implements UserService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private UserDaoJpa userDaoJpa;
    @Override
    public List<User> findAll(String page,String pageSize) {
       if(page==null||page.length()==0){
           List<User> users = userDao.findAll();
           return users;
       }else{
            //分页功能自己写
           PageHelper.startPage(Integer.parseInt(page),Integer.parseInt(pageSize));
           System.out.println(page+"  "+pageSize);
           return null;
       }

    }

    @Override
    public User edit(Integer id) {
        return userDao.findId(id);
    }

    @Override
    public void editTo(User user) {
        userDao.editTo(user);
    }

    @Override
    public void save(User user) {
        userDaoJpa.save(user);

    }
}
